﻿//
// Name: usbDevice.cs
// Project: elektor HiD Temperature Modul
// Author: Michael Odenwald
// Creation Date: 10.05.2013 
//

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using usbGenericHidCommunications;
using System.Diagnostics;

namespace WindowsApp
{
    /// <summary>
    /// This is the implementation of the usbDevice with his service methodes based on the
    /// usbGenericHidCommunication Class
    /// </summary>
    class usbDevice : usbGenericHidCommunication
    {
        /// <summary>
        /// Class constructor - place any initialisation here
        /// </summary>
        /// <param name="vid"></param>
        /// <param name="pid"></param>
        public usbDevice(int vid, int pid)
            : base(vid, pid)
        {
        }

        /// <summary>
        /// USB HiD Temperatur Modul Methode GetTemeratur()
        /// </summary>
        public bool SendDataToAtmel(UInt16 visitCount)
        {
            // Declare our output buffer
            Byte[] outputBuffer = new Byte[5];

            // Byte 1 must be set to our command
            outputBuffer[0] = 10;
            outputBuffer[1] = (Byte)(visitCount >> 8);
            outputBuffer[2] = (Byte)visitCount;
            outputBuffer[3] = 3;
            outputBuffer[4] = 5;

            // Perform the write command
            bool success;
            success = setFeatureReport(outputBuffer);

            // We can't tell if the device receieved the data ok, we are
            // only indicating that the write was error free.
            return success;
        }
    }
}
